//
//  LendRecordViewController.m
//  ZYZB
//
//  Created by ENERGY on 2018/7/23.
//  Copyright © 2018年 ENERGY. All rights reserved.
//

#import "LendRecordViewController.h"
#import "InterestDetailTableViewCell.h"
@interface LendRecordViewController ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong)UIView * topBarView;
@property (nonatomic, strong)UITableView * tableView;
@end

@implementation LendRecordViewController
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:YES];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = @"出借记录";
    //返回按钮
    UIButton * backBtn = [[UIButton alloc] initWithFrame:CGRectMake(18/WIDTH_6_SCALE, 14/WIDTH_6_SCALE + 24 + 20, 24/WIDTH_6_SCALE, 30/WIDTH_6_SCALE)];
    [backBtn addTarget:self action:@selector(backBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [backBtn setImage:[UIImage imageNamed:@"out"] forState:UIControlStateNormal];
    UIBarButtonItem * leftItem = [[UIBarButtonItem alloc] initWithCustomView:backBtn];
    self.navigationItem.leftBarButtonItem = leftItem;
    //构造头部bar
    [self setUpTopBar];
    if (@available(iOS 11.0, *)) {
        self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }else {
        self.automaticallyAdjustsScrollViewInsets = NO;
    }
    [self.view addSubview:self.tableView];
    
}
#pragma mark - init
- (void)setUpTopBar{
    self.topBarView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 45/WIDTH_6_SCALE)];
    self.topBarView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.topBarView];
    int labW = (SCREEN_WIDTH - 36/WIDTH_6_SCALE)/3;
    //投标人
    UILabel * timeLab = [[UILabel alloc] initWithFrame:CGRectMake(18/WIDTH_6_SCALE, 0, labW, self.topBarView.height - 1/WIDTH_6_SCALE)];
    [self label:timeLab withFont:DEF_FontSize_12 withText:@"投标人" withTextColor:[UIColor blackColor] withTextAlignment:NSTextAlignmentLeft withView:self.topBarView];
    //投标时间
    UILabel * accountLab = [[UILabel alloc] initWithFrame:CGRectMake(18/WIDTH_6_SCALE, 0, labW, timeLab.height)];
    accountLab.centerX = SCREEN_WIDTH/2;
    [self label:accountLab withFont:DEF_FontSize_12 withText:@"投标时间" withTextColor:[UIColor blackColor] withTextAlignment:NSTextAlignmentCenter withView:self.topBarView];
    //投标金额
    UILabel * stateLab = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - labW - 18/WIDTH_6_SCALE, 0, labW, timeLab.height)];
    [self label:stateLab withFont:DEF_FontSize_12 withText:@"投标金额" withTextColor:[UIColor blackColor] withTextAlignment:NSTextAlignmentRight withView:self.topBarView];
    //分割线
    UIView * lineView = [[UIView alloc] initWithFrame:CGRectMake(18/WIDTH_6_SCALE, self.topBarView.bottom - 1/WIDTH_6_SCALE, SCREEN_WIDTH - 36/WIDTH_6_SCALE, 1/WIDTH_6_SCALE)];
    
    lineView.backgroundColor = getColor(grayColor);
    [self.topBarView addSubview:lineView];
}
- (UITableView *)tableView{
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, self.topBarView.bottom, SCREEN_WIDTH, SCREEN_HEIGHT - NAVI_HEIGHT - BOTTOM_HEIGHT - self.topBarView.height) style:UITableViewStylePlain];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _tableView.backgroundColor = [UIColor whiteColor];
        [_tableView registerClass:[InterestDetailTableViewCell class] forCellReuseIdentifier:NSStringFromClass([InterestDetailTableViewCell class])];
    }return _tableView;
}
#pragma mark - tableViewDelegate和tableViewDataSource
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    InterestDetailTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([InterestDetailTableViewCell class]) forIndexPath:indexPath];
//    cell.lendRecordModel =
    return cell;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 6;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 45/WIDTH_6_SCALE;
}
#pragma mark - action
- (void)backBtnClick:(UIButton *)sender{
    [self.navigationController popViewControllerAnimated:YES];
}
@end
